package com.modai.advice;

import com.modai.dto.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ：modai
 * @date ：Created in 2021-6-5 19:46
 * @description：全局捕获Controller异常
 */
@RestControllerAdvice
public class ExcepetController {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public CommonResponse<String> exceptHandler(HttpServletRequest req, Exception e) {
        return new CommonResponse<>(CommonResponse.STATUS.FAIL,e.getMessage());
    }
}
